package com.hc.sys;

import java.util.Date;

/**
 * 统一json格式
 * @author H
 *
 */
public class ResponseMsg {
	
	private final String success = "success";
	private final String fail = "fail";

	private Mata mata;		//头信息
	private Object data;	//数据
	
	public ResponseMsg() {
		super();
	}

	public ResponseMsg(Object data, String message, String status, String code) {
		super();
		this.data = data;
		this.mata = new Mata(status, code, message);
	}

	public ResponseMsg success() {
		this.mata = new Mata(success, "200", success);
		return this;
	}
	
	public ResponseMsg success(String message, Object data) {
		this.data = data;
		this.mata = new Mata(success, "200", success);
		return this;
	}
	
	public ResponseMsg fail(String message) {
		this.mata = new Mata(fail, "500", fail);
		return this;
	}
	
	public Object getData() {
		return data;
	}

	public void setData(Object data) {
		this.data = data;
	}

	public Mata getMata() {
		return mata;
	}

	public void setMata(Mata mata) {
		this.mata = mata;
	}

	/**
	 * 头信息
	 * @author H
	 *
	 */
	public class Mata {
		private String status;
		private String code;
		private String message;
		private Date date = new Date();
		public Mata(String status, String code, String message) {
			super();
			this.status = status;	//状态 是否成功
			this.code = code;		//状态码
			this.message = message;	//消息
		}
		public String getStatus() {
			return status;
		}
		public void setStatus(String status) {
			this.status = status;
		}
		public String getCode() {
			return code;
		}
		public void setCode(String code) {
			this.code = code;
		}
		public String getMessage() {
			return message;
		}
		public void setMessage(String message) {
			this.message = message;
		}
		public Date getDate() {
			return date;
		}
		public void setDate(Date date) {
			this.date = date;
		}
		
	}
}
